Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

replace grunt with web-ext #37

Open
wants to merge 9 commits into
base: master
Choose a base branch
from

Conversation

shinenelson
Copy link

web-ext is a tool that is designed specifically for the development
of web extensions. It provides functionality like auto-loading the web
extension in the browser and watching the source file for changes and
automatically reloading the web extension in the browser.

This supersedes the dependency on grunt because grunt cannot
handle the automatic loading of the web-extension into the browser.
And that is obviously because grunt is a generic tool.

When there is a tool that is designed specifically for the purpose of
development of web extensions that provides better functionality, we
should migrate to it.

web-ext has additional features that can be utilized, but I was only
targeting existing feature-parity.

For example, it has an option where the path to a browser binary can
be provided and the tool will attempt to open the web extension with
that binary. This could be useful when one wants to test on other
chromium-based browsers like Opera, Edge Chromium, Brave, Vivaldi,
etc. I think using the chromiumBinary option would probably work,
but I have not tested it ( that is also why I have not changed the
Opera and Edge Chromium sections in the CONTRIBUTING document )

migrate the `grunt test` task to package.json. `npm test` is the new
alternative command.

this is the first ( and easiest ) step to eliminating `grunt` as a
dependency for the project.
There were 2 divergences in the `manifest.json` files :
- `"applications"` block in the firefox manifest which specified the
  minimum supported version of the extension in the browser
- different icon sizes in the default `manifest.json`

This divergence seemed trivial to be maintained separately. Merging and
running the extension from the merged `manifest.json` file did not throw
any major errors in the running of the extension on Firefox as well as
Chromium.

It does not seem sensible to maintain 2 separate `manifest.json` files
for the extension unless there are other chromium-based browsers who use
the `"applications"` block specifically for something else or some other
browser that accepts only one icon in the manifest.
Now that the only minor divergence in the source code have been merged,
the `src` directory can be used as the single source of truth for both
source code as well as distribution code. There is nothing that needs to
be compiled or transpiled that would require a separate dedicated
distribution directory.
because web-ext run already watches, live reloads and also serves the web
extension to the desired browser described by `npm run -- serve:firefox`
or `npm run -- serve:chromium`
`npm` has a built-in `pack` command that can compress the repository (
or specific `files` in the repository ) and generate a tarball.
Additionally, it also adds some default files like the README, LICENSE
and CHANGELOG for posterity.
The output tarball is also aptly named in the format
`<project-name>-<version-string>.tgz`

reference : https://stackoverflow.com/a/55220535

While the tarball can be generated by running the `npm pack` command,
for sake of backward-compatibility of existing `npm` scripts, it has
been assigned to the `package` script replacing the `grunt package`
alias.
remove all remaining traces of grunt from the project
`a0bc2c0` blindly migrated the `grunt` alias `test` without looking at
the script's semantics.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant